package org.jctc.els.modules.biz.service.permissions.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jctc.els.modules.biz.mapper.permissions.PermissionsMapper;
import org.jctc.els.modules.biz.service.permissions.IPermissionsService;
import org.jctc.els.modules.biz.entity.permissions.Permissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
 * <p>
 * 权限表 服务实现类
 * </p>
 *
 * @author lyh
 * @since 2021-02-26
 */
@Service
public class PermissionsServiceImpl implements IPermissionsService {

    @Autowired
    private PermissionsMapper permissionsMapper;

    @Override
    public boolean save(Permissions permissions){
        return permissionsMapper.insert(permissions)>0;
    }

    @Override
    public boolean remove(Long id){
        return permissionsMapper.deleteById(id)>0;
    }

    @Override
    public boolean edit(Permissions permissions){
        return permissionsMapper.updateById(permissions)>0;
    }

    @Override
    public  Page<Permissions> selectListByPage(Integer pageNum, Integer pageSize){
    Page<Permissions> permissionsPage = new Page<>(pageNum, pageSize);
    Permissions permissions = new Permissions();

    return (Page<Permissions> )  permissionsMapper.selectPage(permissionsPage, Wrappers.query(permissions));
    }

    @Override
    public Permissions selectById(Long id){
        return  permissionsMapper.selectById(id);
    }
}
